import {
  adminSystemIndex
} from '@/api/setting/setting'
import {
  crmSettingConfigData
} from '@/api/setting/setting'
import Lockr from 'lockr'

/** 记录 侧边索引 */
const app = {
	state: {
		systeminfo:{
			name:"",
			logo:""
		},
		sidebar: {
			activeIndex: '' // 目前激活的 行
		},
		navbar: {
			activeIndex: '' // 导航目前是第几个 个人中心需要
		}
	},

	mutations: {
		SET_ACTIVEINDEX: (state, path) => {
			state.sidebar.activeIndex = path
		},
		SET_NAVACTIVEINDEX: (state, path) => {
			state.navbar.activeIndex = path
		},
		SET_SYSTEMINFO: (state, info) => {
			state.systeminfo = info
		}
	},

	actions: {
		// 登录
		SystemLogoAndName({
			commit
		}) {
			return new Promise((resolve, reject) => {
				adminSystemIndex().then(response => {
					commit('SET_SYSTEMINFO', response.data)
					Lockr.set('systeminfo', response.data)
					resolve(response)
				}).catch(error => {
					reject(error)
				})
			})
		}
	}
}

export default app
